package com.cc.myblog.demo.Common;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;

/**
 * @author cc
 * @date 2021/7/19 20:31
 * @Description
 */
@Data
public class Result implements Serializable {

    private int code;
    private String message;
    private Object data;

    public static Result succ(int code,String mesage,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(mesage);
        result.setData(data);
        return result;
    }
    public static Result succ(){
        Result result = new Result();
        result.setCode(ResultCode.Requesst_Success.getCode());
        result.setMessage(ResultCode.Requesst_Success.getMessage());
        result.setData(null);
        return result;
    }
    public static Result succ(Object data){
        Result result = new Result();
        result.setCode(ResultCode.Requesst_Success.getCode());
        result.setMessage(ResultCode.Requesst_Success.getMessage());
        result.setData(data);
        return result;
    }

    public static Result fail(int code,String mesage,Object data){
        return fail(ResultCode.Requess_Fail.getCode(),ResultCode.Requess_Fail.getMessage(),data);
    }
    public static Result fail(String mesage){
        return fail(ResultCode.Requess_Fail.getCode(),mesage,null);
    }
}
